package com.blb.edusearchservice.controller;


import com.blb.edusearchservice.pojo.PageEntity;
import com.blb.edusearchservice.service.ICourseIndexService;
import com.blb.pojo.Course;
import com.blb.pojo.ResponseResult;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("search")
@SpringBootApplication(scanBasePackages = {"com.blb.config","com.blb.edusearchservice"})
public class CourseIndexController {
    @Resource
    private ICourseIndexService iCourseIndexService;


    @GetMapping("init-course-index")
    private ResponseResult init(){
        iCourseIndexService.initCourseIndex();
        return ResponseResult.ok("ok");
    }

    @PostMapping("course")
    private ResponseResult getCourse(@RequestBody Map<String,String> map){
        PageEntity<Course> coursePageEntity = iCourseIndexService.searchCoursePage(map);
        return ResponseResult.ok(coursePageEntity);
    }


}
